package com.bytedance.scenedemo.benchmark.performance;

import com.bytedance.scenedemo.ResourceTable;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.agp.window.dialog.ToastDialog;

/**
 * Created by JiangQi on 8/21/18.
 */
public class EmptyAppCompatAbility extends Ability{

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_emptyappcompat_ability);
        long a = System.currentTimeMillis() - PerformanceDemo.getStartTimestamp();
        showToast("启动耗时："+a+"ms");
    }

    /**
     * Toast弹框
     * @param content 内容
     */
    protected void showToast(String content){
        Component toastLayout = LayoutScatter.getInstance(getContext())
                .parse(com.bytedance.scene.ResourceTable.Layout_layout_toast, null, false);
        Text toastText = (Text) toastLayout.findComponentById(com.bytedance.scene.ResourceTable.Id_text_msg_toast);
        toastText.setText(content);
        new ToastDialog(getContext())
                .setComponent(toastLayout)
                .setTransparent(true)
                .show();
    }
}